import { CodeEnum } from './enum'

/**
 * 默认配置
 */
export const DEFAULT_CONFIG = {
  id: '',
  enabled: true,
  showSubLine: true,
  labelBeforeSpanActiveStyle: {
    background: 'rgba(26, 115, 232, 0.8)'
  },
  textSelectionStyle: {
    userSelect: 'none'
  }
}

export type DefaultConfig = Partial<typeof DEFAULT_CONFIG>

// 业务参数
export interface ServiceParams {
  taskId?: string
  [key: string]: any
}

/**
 * 响应码
 */

export type ResMassage = {
  type: 'SUCCESS' | 'ERROR' | 'INFO'
  code?: CodeEnum
  message: string
  data?: any
}

export type UpdateFunc = (data: ResMassage) => void

export type EntityLabelLocationInfo = {
  start?: number
  end?: number
  onlyId?: string
  labelId?: string
  labelName?: string
  labelColor?: string
  text?: string
}

/**
 * 辅助线模板
 */
export const subLineTemplate = `
<div id="sub-line" data-sub-line-show="false" class="sub-line">
	<svg width="100%" height="100%">
		<defs>
			<marker
				id="markerCircle"
				marker-width="6"
				marker-height="6"
				ref-x="5"
				ref-y="3"
			>
				<circle
					cx="5"
					cy="5"
					r="2"
					style="stroke: '#f3ca97'; fill: '#fff'"
				></circle>
			</marker>
			<marker
				id="markerArrow"
				markerWidth="10"
				markerHeight="10"
				refX="7"
				refY="4"
				orient="auto"
			>
				<path
					d="M0,0 L7,4 L0,8 L0,0"
					style="stroke:#f3ca97;fill:#f3ca97;"
				></path>
			</marker>
		</defs>
		<path
			id="sub-line-path"
			stroke="#f3ca97"
			stroke-width="2"
			style="marker-end:url(#markerArrow)"
			fill="none"
		></path>
	</svg>
</div>
`
